package io.dy.controller;

import io.dy.model.OrderModel;
import io.dy.service.OrderService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author dmj
 * @date 2023年10月12日 下午9:57
 */
@RestController
@RequestMapping("/dy/order")
@RequiredArgsConstructor
public class OrderController {

    private final OrderService orderService;

    @GetMapping
    public List<OrderModel> searchAllOrder(){
        return orderService.list();
    }


    @PostMapping
    public Boolean createOrder(@RequestBody OrderModel orderModel){
        return orderService.createOrderAndDeductionBalance(orderModel);
    }
}
